new Vue({
    el: '#main',
    data: {
        gameName: '-',
        gameAsset: {
            nickname: "-",
            userHead: "./images/nrng/tou1@2x.png",
            total_profitrate: "-",
            total_balance: "-",
            ranknum: "-",
            position: '-',
            initmoney: '-',
            market_balance: "-",
            income_balance: "-",
            avail_balance: "-",
            week_increaserate: "-",
            max_drawdown: '-',
            week_profit: '-',
            isNone: true,
            isRed: false,
            isGreen: false
        },
        gamePosition: {
            list: []
        }
    },
    computed: {
        holdRate: function () {
            var nocolor = true, redcolor = false, greencolor = false
            if (!isNaN(this.gameAsset.income_balance)){
                nocolor = false
                this.gameAsset.income_balance = Number(this.gameAsset.income_balance).toFixed(2)
                if (Number(this.gameAsset.income_balance) >= 0) {
                    redcolor = true
                    this.gameAsset.income_balance = '+' + this.gameAsset.income_balance
                } else {
                    greencolor = true
                }
            }
            return {
                'rateline': true,
                'green-value': greencolor,
                'red-value': redcolor,
                'nocolor-value': nocolor
            }
        }
    },
    components: {
        'download': Download
    },
    mounted () {
        this.fetchData()
    },
    methods: {
        fetchData () {
            var self = this;

            $.ajax({
                url: getUrlParam("url"),
                type: "get",
                dataType: "jsonp",
                contentType: 'charset=UTF-8',
                success: function (data) {
                },
                error: function (e) {
                }
            });
            function niurenshare(data) {
                console.log("我的比赛详情分享初始参数：", data);
                self.gameName = data.gameName
                self.gameAsset = data.gameAsset;
                self.gamePosition = data.gamePosition;
                //控制累计收益率的背景颜色
                if (!isNaN(self.gameAsset.total_profitrate)) {
                    self.gameAsset.isNone = false;
                    self.gameAsset.total_profitrate = Number(self.gameAsset.total_profitrate).toFixed(2)
                    if (Number(self.gameAsset.total_profitrate) >= 0) {
                        self.gameAsset.total_profitrate = '+' + self.gameAsset.total_profitrate
                        self.gameAsset.isRed = true;
                    } else {
                        self.gameAsset.isGreen = true;
                    }
                }
                document.title = self.gameName;
                var title = "大王！小的探到" + data.gameAsset.nickname + "比赛持仓页面";
                var content = "欧~~快快呈上"
                //微信分享
                window.weixinShare(title, content, "https://dl.app.gtja.com/nrng/shareimages/bisai1.png", window.location.href);
            }

            window.niurenshare = niurenshare;

            var kv = {"usercode": getUrlParam("userCode"), "k2": ""};
            window.TDAPP.onEvent("11011", "", kv);
            window.TDAPP.send();
        }
    }
})




